//
//  Texture.hpp
//  STDRenderSDK
//
//  Created by 陈学明 on 2023/3/12.
//

#ifndef STDSTexture_hpp
#define STDSTexture_hpp

#include <stdio.h>
#include "STDSOpenGL.h"
#include "STDSObject.h"
class STDSTexture: public STDSObject {
    
public:
    
    STDSTexture(int _w, int _h);

    STDSTexture(int _w, int _h, GXNS_GL(GLenum) _f);

    STDSTexture(GLuint _tid, int _w, int _h, bool _del = true);

    STDSTexture(const unsigned char *_data, int _w, int _h, GXNS_GL(GLenum) f = GXNS_GL(GL_RGBA), bool _mp = false);

    ~STDSTexture();

    void setTexture(GLuint _tid, int _w, int _h, bool _del = true);

    void load(const unsigned char *_data, int _w, int _h, GXNS_GL(GLenum) _f = GXNS_GL(GL_RGBA), bool _mp = false);

    void update(const unsigned char *_data, int _w, int _h, GXNS_GL(GLenum) _f = GXNS_GL(GL_RGBA), bool _mp = false);

    void active_oes();

    void bind();

    void unbind();

    void active(int i);

    void inactive(int i);

    void setWrapMode(GXNS_GL(GLenum) _wrapS, GXNS_GL(GLenum) _wrapT);

    void setFilterMode(GXNS_GL(GLenum) _minFilter, GXNS_GL(GLenum) _maxFiter);

    bool ifWork();

    bool isSize(int _w, int _h);

    GLuint getId();

    int getWidth();

    int getHeight();

private:
    void _resetMode();

    void _release();

private:
    STDSTexture(){};

    STDSTexture(const STDSTexture &);

    STDSTexture &operator=(const STDSTexture &a);

    GLuint mTexId{TEXTURE_NON};
    bool mbCreated{true};
    int mSizeW{0};
    int mSizeH{0};

    GLenum mFormat{GL_RGBA};
    GLenum mWrapS{GL_CLAMP_TO_EDGE};
    GLenum mWrapT{GL_CLAMP_TO_EDGE};
    GLenum mMinFilter{GL_LINEAR};
    GLenum mMaxFilter{GL_LINEAR};
};
#endif /* Texture_hpp */
